<ix-modal-header
  [requiredRoles]="requiredRoles"
  [title]="isNew ? ('Add Dataset' | translate) : ('Edit Dataset' | translate)"
  [loading]="isLoading()"
></ix-modal-header>

<mat-card>
  <mat-card-content>
    <form class="ix-form-container" [formGroup]="form" (submit)="onSubmit()">
      <ix-name-and-options
        [existing]="existingDataset"
        [parent]="parentDataset"
        (formValidityChange)="isNameAndOptionsValid = $event"
      ></ix-name-and-options>
      @if (isAdvancedMode && isNew) {
        <ix-quotas-section
          (formValidityChange)="isQuotaValid = $event"
        ></ix-quotas-section>
      }
      @if (isNew) {
        <ix-encryption-section
          [parent]="parentDataset"
          [advancedMode]="isAdvancedMode"
          (formValidityChange)="isEncryptionValid = $event"
        ></ix-encryption-section>
      }
      <ix-other-options-section
        [existing]="existingDataset"
        [parent]="parentDataset"
        [datasetPreset]="datasetPreset"
        [advancedMode]="isAdvancedMode"
        (advancedModeChange)="onSwitchToAdvanced()"
        (formValidityChange)="isOtherOptionsValid = $event"
      ></ix-other-options-section>

      <ix-form-actions>
        <button
          *ixRequiresRoles="requiredRoles"
          mat-button
          type="submit"
          color="primary"
          ixTest="save"
          [disabled]="form.invalid || isLoading() || !areSubFormsValid"
        >
          {{ 'Save' | translate }}
        </button>
        <button
          mat-button
          type="button"
          ixTest="toggle-advanced"
          (click)="toggleAdvancedMode()"
        >
          {{ isAdvancedMode ? ('Basic Options' | translate) : ('Advanced Options' | translate) }}
        </button>
      </ix-form-actions>
    </form>
  </mat-card-content>
</mat-card>
